﻿using System;
using System.Text;

public static partial class Extensions
{
    private static readonly char[] _rule = new char[] {'0','1','2','3','4','5','6','7','8','9',
        'A','B','C','D','E','F','G','H','J','K',
        'L','M','N','P','Q','R','S','T','U','V',
        'W','X','Y','Z',};
   /// <summary>
   /// 转34进制
   /// </summary>
   /// <param name="this"></param>
   /// <param name="len"></param>
   /// <returns></returns>
    public static string ConverttoRadix34Str(this Int64 @this, int len)
    {
        if (@this < 0 | @this >= Math.Pow(34, len))
        {
            throw new ArgumentException(String.Format("内部错误。（num={0}）", @this));
        }
        var sb = new StringBuilder();
        for (int i = 1; i <= len; i++)
        {
            sb.Insert(0, _rule[@this % 34]);
            @this /= 34;
        }
        return sb.ToString();
    }
}